package com.haoxin.ai_course.modules.course.controller.admin;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.haoxin.ai_course.common.annotation.SysLog;
import com.haoxin.ai_course.common.base.AbstractController;
import com.haoxin.ai_course.common.utils.R;
import com.haoxin.ai_course.modules.course.entity.AcCourseNode;
import com.haoxin.ai_course.modules.course.service.AcCourseNodeService;

import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;



/**
 * 课程环节表
 * 
 * @author xingxiangguo
 * @email bugcn@qq.com
 * @date 2022-06-10 17:24:28
 */
@RestController
@AllArgsConstructor
@RequestMapping("/course/accoursenode")
@Api(value="api",tags="后台-课程环节管理")
public class AdminAcCourseNodeController  extends AbstractController {
    private final  AcCourseNodeService acCourseNodeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("course:accoursenode:list")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        QueryWrapper<AcCourseNode> queryWrapper = new QueryWrapper<>();
        IPage<AcCourseNode> sysConfigList = acCourseNodeService.page(mpPageConvert.<AcCourseNode>pageParamConvert(params),queryWrapper);
        return R.ok().put("page", mpPageConvert.pageValueConvert(sysConfigList));
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("course:accoursenode:info")
    public R info(@PathVariable("id") Integer id){
        return R.ok().put("acCourseNode", acCourseNodeService.getById(id));
    }


    /**
     * 新增课程环节表
     */
    @SysLog("新增课程环节表数据")
    @RequestMapping("/save")
    @RequiresPermissions("course:accoursenode:save")
    public R save(@RequestBody AcCourseNode acCourseNode){
        acCourseNodeService.save(acCourseNode);
        return R.ok();
    }


    /**
     * 修改
     */
    @SysLog("修改课程环节表数据")
    @RequestMapping("/update")
    @RequiresPermissions("course:accoursenode:update")
    public R update(@RequestBody AcCourseNode acCourseNode){
		acCourseNodeService.updateById(acCourseNode);
        return R.ok();
    }


    /**
     * 删除
     */
    @SysLog("删除课程环节表数据")
    @RequestMapping("/delete")
    @RequiresPermissions("course:accoursenode:delete")
    public R delete(@RequestBody Integer[] ids){
		acCourseNodeService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }
	
}
